package com.xdog.okx.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.xdog.okx.service.IOkxBlockService;
import com.xdog.okx.utils.OkxApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * OKX区块链数据服务实现类
 * 提供区块链基础数据查询功能
 */
@Slf4j
@Service
public class OkxBlockServiceImpl implements IOkxBlockService {

    @Override
    public JSONObject getBlockDetails(String chainShortName, String height) {
        String requestPath = "/api/v5/xlayer/block/block-fills";

        Map<String, String> queryParams = new HashMap<>();
        queryParams.put("chainShortName", chainShortName);
        queryParams.put("height", height);

        return OkxApiUtil.get(requestPath, queryParams);
    }

    @Override
    public JSONObject getBlockList(Map<String, String> params) {
        String requestPath = "/api/v5/xlayer/block/block-list";
        return OkxApiUtil.get(requestPath, params);
    }

    @Override
    public JSONObject getBlockTransactionList(Map<String, String> params) {
        String requestPath = "/api/v5/xlayer/block/transaction-list";
        return OkxApiUtil.get(requestPath, params);
    }

    @Override
    public JSONObject getBlockTransactionListMulti(Map<String, String> params) {
        String requestPath = "/api/v5/xlayer/block/transaction-list-multi";
        return OkxApiUtil.get(requestPath, params);
    }
}